Skip to content

feat: add support for mldsa44-ed25519 (draft-miller-sshm-composite-sigs) - #583

Merged
tarcieri merged 16 commits into
RustCrypto:masterfrom
quexten:mldsa-eddsa
Dec 3, 2026
Merged

tarcieri merged 16 commits into
RustCrypto:masterfrom
quexten:mldsa-eddsa

Conversation

@quexten

@quexten quexten commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Adds support for https://www.ietf.org/archive/id/draft-miller-sshm-composite-sigs-01.html mldsa44-ed25519 composite keys. Given that openssh currently does not have plans to support raw mldsa keys, this superseeds my other PR.

I've tested support for interoperability on OpenSSH_10.5p1, OpenSSL 3.6.3 9 Jun 2026 in SSH agent (I signed and verified a file signature via SSH agent using this PR's implementation).

(With some further patches in Bitwarden's SSH Agent):
image

@quexten quexten changed the title mldsa eddsa add support for mldsa44-ed25519 Aug 28, 2026
Comment thread ssh-key/src/mldsa_eddsa.rs Resolved
Comment thread ssh-key/src/mldsa_eddsa.rs Resolved
@quexten quexten changed the title add support for mldsa44-ed25519 add support for mldsa44-ed25519 (draft-miller-sshm-composite-sigs) Aug 28, 2026
@quexten
quexten marked this pull request as ready for review August 28, 2026 08:42
@quexten quexten changed the title add support for mldsa44-ed25519 (draft-miller-sshm-composite-sigs) feat: add support for mldsa44-ed25519 (draft-miller-sshm-composite-sigs) Aug 28, 2026
@baloo

baloo commented Aug 28, 2026

Copy link
Copy Markdown
Member

If I read the draft correctly, public keys, private keys and signature are just "append mldsa(44|87) with (eddsa|ecdsa) (public|private|signature)" together.

Would it be possible to make those composite using a macro or something and reuse the existing ed25519/ecdsa keys?
I'd bring back the implement you had in your previous PR and keep it private, and expose it only through the composite.

I haven't tried it. Happy to.

@baloo

baloo commented Aug 28, 2026

Copy link
Copy Markdown
Member

well, openssh doesn't appear to have mldsa87-p384 support at the moment.

@quexten

quexten commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

@baloo I'm happy to make the changes, but currently really only mldsa44-ed25519 is supported. Openssh specifically state that they have no plans to add pure mldsa (though as mentioned in the original PR some ssh clients have added it), so I feel that unless there is a change of direction from openssh to make it likely that pure mldsa will be supported, it's not worth introducing the complexity currently. openssh/openssh-portable#703 (comment)

Openssh also does not currently support mldsa87-p384 as you point out.

As to the question; yes private key seeds, public keys, and signatures are just concatenated respectively in the encoding, however for signatures specifically 1. the mldsa context is set to a specific label that is composite specific, and 2. they both don't directly sign the data, but they sign a commitment to a prefix, the label, the ctx (and length of it), and the data. So the sign operations from the underlying SSH keys are not directly usable / we would at minimum have to expose a private function for the mldsa keys that exposes the context parameter, but macros could do a lot of the lifting when adding mldsa87-p384 support.

LMK which path you prefer

@baloo

baloo commented Aug 28, 2026

Copy link
Copy Markdown
Member

Yeah, I've missed the message it signed was not similar. I'm just worried about the code duplication you're introducing here.

@quexten
quexten marked this pull request as draft September 2, 2026 11:19
@quexten

quexten commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@baloo I restructured the PR to have ml-dsa be separate and pub(crate)`, and to have the composite sig be generated by a macro. Would you mind checking whether this matches your expectation?

I think the other key type that openssh doesn't support yet but the draft spec supports, we should easily be able to add later using the macro.

@quexten
quexten marked this pull request as ready for review September 9, 2026 12:46
Inf1mum added a commit to Inf1mum/openidea that referenced this pull request Nov 18, 2026
Offer the post-quantum hybrid host key / signature algorithm
ssh-mldsa44-ed25519 (ML-DSA-44 + Ed25519, draft-miller-sshm-composite-sigs,
wire-compatible with OpenSSH 10.x) in addition to the russh defaults, so
PQC-only servers negotiate it; the classical algorithms stay ahead of it in
the offered list, so servers that have them are unaffected.

russh 0.65 offers and negotiates the algorithm, but ssh-key 0.7.0-rc.11 can
neither represent its plain wire name (AlgorithmName requires name@domain)
nor verify the composite signature, so ssh-key is carried as a vendored
[patch.crates-io] fork with the missing pieces until upstream lands them
(RustCrypto/SSH#583): the MlDsa44Ed25519 algorithm and key variants behind a
mldsa-eddsa feature, the composite codec (public key 1344, signature 2484,
seed pair 64) and ML-DSA-44 (ml-dsa) + Ed25519 sign/verify over the composite
message representative M'. The path entry can be swapped for a pinned git
fork like the existing sqlx one.

Verified against the draft-ietf-lamps-pq-composite-sigs known-answer vectors
shipped with OpenSSH (seed expansion reproduces the published public key, the
OpenSSH-generated composite signature verifies) and end to end against an
in-process russh server offering only ssh-mldsa44-ed25519: ML-KEM-768 KEX,
composite host key verification and composite user key authentication all
succeed.

Refs l0ng-ai#3482

Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
@quexten

quexten commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

@baloo / @tarcieri Hey, since this sat stale for a while, is there any chance we could get it reviewed and merged? If not I'll vendor the changes downstream for our use-case for the time being, but from the GitHub references it seems some other projects want to use them too.

I've resolved the conflicts that have accumulated on the PR since my last work on this now.

@quexten

quexten commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@cjpatton Thank you too for the review! I've addressed all points, but I've left the Randomized (Hedged) vs deterministic signing open, since that's one where I'm not entirely confident on the solution and will defer to @baloo / @tarcieri call on them.

@tarcieri

tarcieri commented Dec 3, 2026

Copy link
Copy Markdown
Member

I will try to get this landed soon, everyone

@alex alex left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit, but I didn't see any functional bugs. (Didn't review for style)

matches!(self, Self::Rsa(_))
}

/// Is this key an ML-DSA key?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably say composite mldsa-ed25519 key

@tarcieri tarcieri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll go ahead and approve this and then look into following up with some changes.

I guess my main reservation has been how composite.rs is implemented and if there were a cleaner, more generic way to implement it that better leverages the existing traits as opposed to the heavily macro-laden approach it's using in addition to defining its own traits.

But we can get this landed as a start, as it seems to interop with OpenSSH 10.6, and I can follow up on that.

@tarcieri
tarcieri merged commit 2849e3b into RustCrypto:master Dec 3, 2026
23 checks passed
@tarcieri

tarcieri commented Dec 3, 2026

Copy link
Copy Markdown
Member

Followup: #653.

I will get a prerelease of this out today, and a final release out hopefully tomorrow.

quexten added a commit to bitwarden/clients that referenced this pull request Dec 3, 2026
The desktop agent can now hold, list and sign with
`ssh-mldsa44-ed25519@openssh.com` keys imported from OpenSSH. The
composite pairs ML-DSA-44 with Ed25519 and verifies only if both halves
do, so it is no weaker than Ed25519 alone while resisting a
store-now-decrypt-later attack on the classic half.

Nothing in the agent filtered on algorithm beyond `PrivateKey`'s
conversion from `ssh_key::PrivateKey`, so the wire protocol, approval
and session-bind paths needed no change.

ssh-key gains the type from a fork pending upstream review
(RustCrypto/SSH#583), pinned through
`[patch.crates-io]` on all three SSH crates, since the revision changes
`Decode::decode` to take `&mut Decoder<impl Reader>`. Drop the patch
once that PR merges and is published.

Key generation still offers only Ed25519: `KeyAlgorithm` in the
published @bitwarden/sdk-internal has no composite variant yet
(bitwarden/sdk-internal#1854).
quexten added a commit to bitwarden/sdk-internal that referenced this pull request Dec 3, 2026
ssh-key does not yet release the `mldsa44-ed25519` composite key type;
RustCrypto/SSH#583 added it and is merged. Point ssh-cipher,
ssh-encoding and ssh-key at upstream master through `[patch.crates-io]`
so all three come from one revision — it changes `Decode::decode` to
take `&mut Decoder<impl Reader>`. Revert once they are published.

ssh-encoding 0.4 changes `Mpint`: `from_positive_bytes` is now the
fallible `from_bytes`, and `as_bytes` returns the unsigned magnitude,
replacing `as_positive_bytes`.

RUSTSEC-2023-0071 (Marvin attack) no longer matches any crate in the
graph, and cargo-deny rejects an ignore entry that matches nothing.

The CXF SSH export fixture changes in its "checkint" field only:
ssh-encoding 0.4 dropped the leading sign byte from `Mpint::as_bytes`,
which shifts the value ssh-key derives from the private exponent. The
key material is byte-identical.
tarcieri added a commit that referenced this pull request Dec 3, 2026
Followup to #583 which provided an ininitial implementation of
`mldsa44-ed25519` compsoite signatures compatible with OpenSSH 10.6.

This change removes quite a bit of indirection and premature
abstractions, leaning on generics and the existing traits instead of
macros.
tarcieri added a commit that referenced this pull request Dec 3, 2026
With #583 and #653 landed, and with all of the dependencies already in
place, this is fairly easy to add as well.

It's not currently implemented by OpenSSH 10.6, but if it were it would
be a nice option for systems which implement NIST standards exclusively
and don't support Ed25519, for example Apple's SEPs.
tarcieri added a commit that referenced this pull request Dec 3, 2026
With #583 and #653 landed, and with all of the dependencies already in
place, this is fairly easy to add as well.

It's not currently implemented by OpenSSH 10.6, but if it were it would
be a nice option for systems which implement NIST standards exclusively
and don't support Ed25519, for example Apple's SEPs.
tarcieri added a commit that referenced this pull request Dec 3, 2026
With #583 and #653 landed, and with all of the dependencies already in
place, this is fairly easy to add as well.

It's not currently implemented by OpenSSH 10.6, but if it were it would
be a nice option for systems which implement NIST standards exclusively
and don't support Ed25519, for example Apple's SEPs.
tarcieri added a commit that referenced this pull request Dec 3, 2026
With #583 and #653 landed, and with all of the dependencies already in
place, this is fairly easy to add as well.

It's not currently implemented by OpenSSH 10.6, but if it were it would
be a nice option for systems which implement NIST standards exclusively
and don't support Ed25519, for example Apple's SEPs.
@tarcieri

tarcieri commented Dec 4, 2026

Copy link
Copy Markdown
Member

This is released in v0.7.0-rc.13

@quexten

quexten commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Sweet, thank you @tarcieri !

quexten added a commit to bitwarden/clients that referenced this pull request Dec 4, 2026
The desktop agent can now hold, list and sign with
`ssh-mldsa44-ed25519@openssh.com` keys imported from OpenSSH. The
composite pairs ML-DSA-44 with Ed25519 and verifies only if both halves
do, so it is no weaker than Ed25519 alone while resisting a
store-now-decrypt-later attack on the classic half.

Nothing in the agent filtered on algorithm beyond `PrivateKey`'s
conversion from `ssh_key::PrivateKey`, so the wire protocol, approval
and session-bind paths needed no change.

ssh-key gains the type from a fork pending upstream review
(RustCrypto/SSH#583), pinned through
`[patch.crates-io]` on all three SSH crates, since the revision changes
`Decode::decode` to take `&mut Decoder<impl Reader>`. Drop the patch
once that PR merges and is published.

Key generation still offers only Ed25519: `KeyAlgorithm` in the
published @bitwarden/sdk-internal has no composite variant yet
(bitwarden/sdk-internal#1854).
quexten added a commit to bitwarden/sdk-internal that referenced this pull request Dec 4, 2026
ssh-key does not yet release the `mldsa44-ed25519` composite key type;
RustCrypto/SSH#583 added it and is merged. Point ssh-cipher,
ssh-encoding and ssh-key at upstream master through `[patch.crates-io]`
so all three come from one revision — it changes `Decode::decode` to
take `&mut Decoder<impl Reader>`. Revert once they are published.

ssh-encoding 0.4 changes `Mpint`: `from_positive_bytes` is now the
fallible `from_bytes`, and `as_bytes` returns the unsigned magnitude,
replacing `as_positive_bytes`.

RUSTSEC-2023-0071 (Marvin attack) no longer matches any crate in the
graph, and cargo-deny rejects an ignore entry that matches nothing.

The CXF SSH export fixture changes in its "checkint" field only:
ssh-encoding 0.4 dropped the leading sign byte from `Mpint::as_bytes`,
which shifts the value ssh-key derives from the private exponent. The
key material is byte-identical.
quexten added a commit to bitwarden/clients that referenced this pull request Dec 4, 2026
The desktop agent can now hold, list and sign with
`ssh-mldsa44-ed25519@openssh.com` keys imported from OpenSSH. The
composite pairs ML-DSA-44 with Ed25519 and verifies only if both halves
do, so it is no weaker than Ed25519 alone while resisting a
store-now-decrypt-later attack on the classic half.

Nothing in the agent filtered on algorithm beyond `PrivateKey`'s
conversion from `ssh_key::PrivateKey`, so the wire protocol, approval
and session-bind paths needed no change.

ssh-key gains the type from a fork pending upstream review
(RustCrypto/SSH#583), pinned through
`[patch.crates-io]` on all three SSH crates, since the revision changes
`Decode::decode` to take `&mut Decoder<impl Reader>`. Drop the patch
once that PR merges and is published.

Key generation still offers only Ed25519: `KeyAlgorithm` in the
published @bitwarden/sdk-internal has no composite variant yet
(bitwarden/sdk-internal#1854).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants